﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DATA
{
   public  class ContactInformationREP
    {
        
        MODELGENERALDataContext context = new MODELGENERALDataContext();
        
     
        public ContactInformationDTO GetContactInformation()
        {
            ContactInformationDTO acc = new ContactInformationDTO();
            try
            {
                var account = context.ContactInformations.First();
                acc.Address = account.address;
                acc.CompanyName = account.companyName;
                acc.Copyright = account.copyright;
                acc.Designed = account.designed;
                acc.Email = account.email;
                acc.Id = account.id;
                acc.Logo = account.logo;
                acc.Phone = account.phone;
                acc.Powered = account.powered;
                acc.ShortName = account.shortName;
                acc.Slogan = account.slogan;
                acc.Website = account.website;
            }
            catch (Exception)
            { 
            
            }
            return acc;
        }

        public bool UpdateContactInformation(ContactInformationDTO account)
        {
            try
            {
                ContactInformation acc = context.ContactInformations.First();
                acc.address = account.Address;
                acc.companyName = account.CompanyName;
                acc.copyright = account.Copyright;
                acc.designed = account.Designed;
                acc.email = account.Email;
                acc.logo = account.Logo;
                acc.phone = account.Phone;
                acc.powered = account.Powered;
                acc.shortName = account.ShortName;
                acc.slogan = account.Slogan;
                acc.website = account.Website;
               
                context.SubmitChanges();
            }

             catch (Exception)
            {
                return false;
            }
            return true;
        }
    }
    
}
